define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user_feedback/index' + location.search,
                    add_url: 'user_feedback/add',
                    edit_url: 'user_feedback/edit',
                    del_url: 'user_feedback/del',
                    multi_url: 'user_feedback/multi',
                    import_url: 'user_feedback/import',
                    table: 'user_feedback',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'venue.name', title: __('所属场馆'),operate:false},
                        {field: 'venue_id', title: __('所属场馆'),addclass: 'selectpage', extend:'data-source="ajax/venue"', defaultValue:Config.vid, visible:false,},
                        //{field: 'user_id', title: __('User_id')},
                        {field: 'user.username', title: __('User.username'), operate: false},
                        {field: 'time', title: __('Time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'content', title: __('Content'), operate: 'LIKE'},
                        {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
                        {field: 'phone', title: __('Phone'), operate: 'LIKE'},
                       // {field: 'ext', title: __('Ext'), operate: 'LIKE'},
                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},

                        //{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                        {field: 'operate', title: __('Operate'), table: table,
                            events: Table.api.events.operate,
                            buttons: [
                                {
                                    name:'check',
                                    text:'处理',
                                    title: __('点击处理'),
                                    icon: 'fa fa-check',
                                    classname: 'btn btn-xs btn-success  btn-ajax',
                                    confirm: '已处理了吗？',
                                    url: 'user_feedback/status',
                                    hidden:function(row){
                                        if(row.status ==1){
                                            return true;
                                        }
                                    }
                                }

                            ],
                            formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});